<template>
  <div class="container">
    <div class="news-ad">
      <image :src="banner" />
    </div>
    <Line :text="'速诚每日招聘信息预览'"> </Line>

    <JobList :needtext="false" :list="jobList"> </JobList>

    <Contact> </Contact>
  </div>

</template>
<script>
  const wxapp = getApp();
  import Line from '@/components/Line'

  import JobList from '@/components/Index/JobList'
  import Contact from '@/components/contact'
  export default {
    data(){
      return{
        jobList:[],
        page: 1,
        banner: '../../static/news-ad.png'
      }
    },
    components:{
      Line,
      JobList,
      Contact
    },
    onShow() {
      //this.getList()
      this.getList()
      this.getCate()
    },
    methods: {
      getList() {
        wx.showLoading({
          title: '加载中',
        })
        var date = new Date();
        let start = new Date(date.getFullYear()+'-'+ (date.getMonth() + 1) +'-'+date.getDate()+' 00:00:00')
        let end = new Date(date.getFullYear()+'-'+(date.getMonth() + 1)+'-'+date.getDate()+' 23:59:59')
        console.log(end.getTime()/1000);

        let that = this
        wx.request({
          url: wxapp.globalData.ROOT_URL, //仅为示例，并非真实的接口地址
          data: {
             siteid: '4' ,
             service: 'App.Hong.Index',
             page: that.page,
             limit: 50,
             table: '4_jobs',
             ftable: '4_jobs_category',
             where: {
               'inputtime > ?': start.getTime()/1000,
               'inputtime < ?': end.getTime()/1000,
             }
          },
          success: function(res) {
            wx.hideLoading()
            that.isLoading = false
            if(res.data.data.result == 0) {
              wx.showToast({
                title: '没有了',
                icon: 'success',
                duration: 2000
              })
              that.isNext = false
            }else {
              let list = res.data.data.result
              if(that.page >1) {
                let jobList = that.jobList
                for(let i in list) {
                  jobList.push(list[i])
                }
                that.jobList = jobList
              }else {
                that.jobList = list
              }
            }
            console.log(that.jobList)

          }
        })
      },
      getCate() {
        let that = this
        wx.request({
          url: wxapp.globalData.ROOT_URL, //仅为示例，并非真实的接口地址
          data: {
             service: 'App.Hong.GetCategory',
             table: '4_jobs_category'
          },
          header: {
              'content-type': 'application/json' // 默认值
          },
          success: function(res) {
            that.navlist = res.data.data.result
            that.banner = that.navlist[1]['thumb'];
          }
        })
      }
    }
  }
</script>
<style scoped>
  .news-ad{
    height: 310rpx;
  }
  .news-ad image{
    width: 100%;
    height: 310rpx;
  }
</style>
